#include "LoginThread.h"

LoginThread::LoginThread(OSCthulhuClient *client)
{
    this->connected = false;
    this->client = client;
    this->start();
}

void LoginThread::run() {
    while(!connected) {
        sleep(1);
        client->login();
        qDebug() << "Attempting to connect to Server.";
    }
    exec();
}

void LoginThread::connectedToServer() {
    connected = true;
}

void LoginThread::disconnectedFromServer() {
    connected = false;
}

void LoginThread::restart() {
    terminate();
    connected = false;
    wait(1);
    start();
}


